package com.hp.springbootwebflux.dao;

import com.hp.springbootwebflux.domain.User;
import org.springframework.data.mongodb.repository.Query;
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;

/**
 * @author dongxing
 **/
@Repository
public interface UserRepository extends ReactiveMongoRepository<User,String> {


    /**
     *
     * 根据年龄查找用户
     *
     * @param start
     * @param end
     * @return
     */
    Flux<User> findAllByAgeIsBetween(int start, int end);

    Flux<User> findUsersByAgeBetween(int start, int end);


    @Query("{ \n" +
            "        \"age\" : {\n" +
            "            \"$gte\" : 50, \n" +
            "            \"$lte\" : 55\n" +
            "        }\n" +
            "    }")
    Flux<User> oldUser();
}
